import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { Query, PageList, queryExam, FileInfo } from "./types";

/**
 * 获取题库分类列表
 * @param Query
 */
export function getExamPage(
  data: Query
): AxiosPromise<PageList[]> {
  return request({
    url: "/study/QuestionsCategory/list",
    method: "post",
    data,
  });
}

/**
 * 获取题库顶级分类列表
 * @param Query
 */
export function getTopList(): AxiosPromise<PageList[]> {
  return request({
    url: "/study/QuestionsCategory/topList",
    method: "post",
  });
}

/**
 * 
 * 获取题库新增
 */
export function getAddList(
  data: any) {
  return request({
    url: "/study/QuestionsCategory/create",
    method: "post",
    data,
  });
}


/**
 * 
 * 获取题库删除
 */
export function getDelList(
  data: any) {
  return request({
    url: "/study/QuestionsCategory/del",
    method: "post",
    data,
  });
}

/**
 * 
 * 获取题库修改
 */
export function getEditList(
  data: any) {
  return request({
    url: "/study/QuestionsCategory/edit",
    method: "post",
    data,
  });
}

/**
 * 获取题库分类列表
 * @param Query
 */
export function getQuestionsList(
  data: queryExam
): AxiosPromise<PageResult<PageList[]>> {
  return request({
    url: "/study/Questions/list",
    method: "post",
    data,
  });
}

/**
 * 新增试题
 * @param Query
 */
export function getQuestionsAdd(
  data: any) {
  return request({
    url: "/study/Questions/create",
    method: "post",
    data,
  });
}

/**
 * 
 * 删除问题
 */
export function getQuestionsDel(
  data: any) {
  return request({
    url: "/study/Questions/del",
    method: "post",
    data,
  });
}

/**
 * 
 * 修改问题
 */
export function getQuestionsEdit(
  data: any) {
  return request({
    url: "/study/Questions/edit",
    method: "post",
    data,
  });
}

/**
 * 获取题库顶级分类列表
 * @param Query
 */
export function getGoryTopList(): AxiosPromise<PageList[]> {
  return request({
    url: "/study/TestPaperCategory/topList",
    method: "post",
  });
}

/**
 * 新增考试分类
 */
export function getCreateAdd(
  data: any) {
  return request({
    url: "/study/TestPaperCategory/create",
    method: "post",
    data,
  });
}

/**
 * 修改考试分类
 */
export function getCreateEdit(
  data: any) {
  return request({
    url: "/study/TestPaperCategory/edit",
    method: "post",
    data,
  });
}

// 考试列表
export function getCreateList(
  data: Query
): AxiosPromise<PageList[]> {
  return request({
    url: "/study/TestPaperCategory/list",
    method: "post",
    data,
  });
}

/**
 * 
 * 删除问题
 */
export function getCreateDel(
  data: any) {
  return request({
    url: "/study/TestPaperCategory/del",
    method: "post",
    data,
  });
}

/**
 * 新增考试
 */
export function getPaperAdd(
  data: any) {
  return request({
    url: "/study/TestPaper/create",
    method: "post",
    data,
  });
}

// 获取试卷列表
export function getPaperList(
  data: queryExam
): AxiosPromise<PageResult<PageList[]>> {
  return request({
    url: "/study/TestPaper/list",
    method: "post",
    data,
  });
}


// 获取试卷详情
export function getPaperInfo(
  data: any) {
  return request({
    url: "/study/TestPaper/info",
    method: "post",
    data,
  });
}

// 修改考试
export function getPaperEdit(
  data: any) {
  return request({
    url: "/study/TestPaper/edit",
    method: "post",
    data,
  });
}


// 删除考试
export function getPaperDel(
  data: any) {
  return request({
    url: "/study/TestPaper/del",
    method: "post",
    data,
  });
}

// 发送考试任务
export function postTaskSend(
  data: any) {
  return request({
    url: "/study/user/send",
    method: "post",
    data,
  });
}


// 消息详情列表
export function messageInfoList(
  data: any) {
  return request({
    url: "/study/user/messageInfoList",
    method: "post",
    data,
  });
}



//  上传文件
export function importing(data: any): AxiosPromise<FileInfo> {

  const formData = new FormData();
  formData.append("file", data);
  return request({
    url: "/study/Questions/importing",
    method: "post",
    data,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
}
